package Utility
{
	import flash.events.MouseEvent;  
    import mx.containers.Box;  
    import mx.containers.DividedBox;  
    import mx.controls.Image; 
	public class DividerBox extends Box  
    {  
        [Embed(source='images/arrow_left.gif')]  
        public static const DividerIcon_left:Class;    
          
        [Embed(source='images/arrow_right.gif')]  
        public static const DividerIcon_right:Class;    
          
        private var image:Image = new Image();  
        private var bOpened:Boolean = false;  
          
        private var dividbox:DividedBox = null;  
          
        public function DividerBox()  
        {  
            super();  
            this.width = 12;  
            this.height = 72;  
            this.clipContent  = true;  
            image.width = 12;  
            image.height = 72;  
            this.toolTip="点击图标可以隐藏或显示功能卡";          
            this.addChild( image );  
            //我这个是在一个HdividedBox中，其默认对dividerbox进行了旋转，所以需要旋转回来。  
  		   	image.rotation = 90;  
			this.buttonMode=true;
            this.addEventListener(MouseEvent.CLICK,onMouseClick);
        }  
          
        override protected function createChildren():void{  
            super.createChildren();  
            dividbox = this.parent.parent.parent as DividedBox;  
            image.source = DividerIcon_left;  
        }  
        
          
        public function onMouseClick(event:MouseEvent):void{  
            if(bOpened){ 
                image.source = DividerIcon_right;  
                dividbox.getChildAt(0).width = 0;  
                bOpened = false;  
            }else{  
                bOpened = true;  
                image.source = DividerIcon_left;  
                dividbox.getChildAt(0).width = 180;  
            }  
        }  
          
    }  
}  